﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using Htss.Platform.Web;

namespace DreamBox.Web.Box.posts
{
    public class listBox:ControllerBox
    {
        public ActionResult Load()
        {
            //
            int p = Request.QueryString["p"] != null ? Htss.Platform.Core.Transform.GetInt(Request.QueryString["p"], 1) : 1;
            int CID = RequestContext.RouteData.Values["id"] != null ? Htss.Platform.Core.Transform.GetInt(RequestContext.RouteData.Values["id"].ToString(), 0) : 0;
            string where = string.Empty;
            if (CID != 0)
            {
                where = "CID=" + CID;
            }
            ViewData["CID"] = CID;
            //加载分类数据
            DAL.PSelect ps = new DAL.PSelect();
            ViewDbTable["ListForClass"] = ps.SelectForReader("dbox_PostsClass", "*", "IsStatus=1");
            //分页数据处理
            DAL.GetPager page = new DAL.GetPager();
            ViewDbTable["ListData"] = page.GetPageData(p, "dbox_v_posts", "PostsID", where, 1);
            ViewData["ListPage"] = page.GetPage(p, where, "dbox_v_posts", "PostsID", "/posts/list" + (CID != 0 ? "/" + CID : ""))[0];

            return View("posts_list");
        }
    }
}
